import cfg from "../../lib/config/config.js"
const ROLE_MAP = {
  admin: "群管理",
  owner: "群主",
  member: "群员"
}

export class invite extends plugin {
  constructor() {
    super({
      name: "自动同意进群",
      dsc: "邀请自动进群",
      event: "request.group.invite"
    })
  }

  async accept() {
    logger.mark(`[自动同意进群]：${this.e.group_name}：${this.e.group_id}`)
    this.e.approve(true)
    Bot.pickFriend(cfg.masterQQ[0]).sendMsg([
      "邀请进群",
      `目标群号：${this.e.group_id}\n`,
      `目标群名：${this.e.group_name}\n`,
      `邀请人账号：${this.e.user_id}\n`,
      `邀请人昵称：${this.e.nickname}\n`,
      `邀请人群身份：${ROLE_MAP[this.e.role]}\n`,
      `邀请码：${this.e.seq}\n`,
      "已自动同意该邀请"
    ])
  }
}